<template>
	<view class="">
		<view class="off">
			<view class="off-img">
				<image src="../../static/images/banner-img.jpg" class="off-image"></image>
			</view>
			<view class="off-info">
				<view class="off-name">{{resData.coupon.name}}<text class="red">{{resData.coupon.money}}元</text></view>
				<view class="off-time">活动时间：{{resData.coupon.time}} 至 {{resData.coupon.ling_time}}</view>
			</view>
		</view>
		<rich-text :nodes="resData.coupon.content_html" class="wrap"></rich-text>
		<view class="btn-wrap" :style="'padding-bottom: '+buBottom+'rpx'">
			<view class="btn">
				<view class="btn1" @click="get_in">
					<image src="../../static/images/ticket.png" class="ticket-icon"></image>
					<view class="btn-p">领取优惠</view>
				</view>
			</view>
		</view>

		<view class="btn-margin" :style="'padding-bottom: '+buBottom+'rpx'"></view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				buBottom: 0,
				options: '',
				resData: []
			}
		},

		/**
		 * 生命周期函数--点击事件集合
		 */
		methods: {
			get_info(){
				var post_data = {
					id: this.options.id
				}
				this.$http({
					url: 'Api/Work/coupon_info',
					data: post_data,
					hideLoading: true,
					success: res => {
						this.resData = res.data
					}
				})
			},
			get_in(){
				var post_data = {
					id: this.options.id
				}
				this.$http({
					url: 'Api/Work/get_coupon',
					data: post_data,
					hideLoading: true,
					success: res => {
						if (res.code == 1){
							uni.showModal({
								title: '温馨提示',
								content: res.msg,
								showCancel: false,
								confirmText: '我知道了',
								success: res => {
									uni.reLaunch({
										url: '/pages/index/index'
									})
								}
							})
						}
					}
				})
			}
		},

		/**
		 * 生命周期函数--监听页面加载
		 */
		onLoad(options) {
			this.options = options
			this.get_info()
		},

		/**
		 * 生命周期函数--监听页面初次渲染完成
		 */
		onReady() {

		},

		/**
		 * 页面相关事件处理函数--监听用户下拉动作
		 */
		onPullDownRefresh() {

		},

		/**
		 * 页面上拉触底事件的处理函数
		 */
		onReachBottom() {

		},
	}
</script>

<style>
	.wrap {
		padding: 30rpx;
	}

	.off {
		box-shadow: 0 10rpx 10rpx rgba(0, 0, 0, .1);
	}

	.off-image {
		height: 350rpx;
	}

	.off-info {
		padding: 20rpx;
		display: flex;
		flex-direction: column;
		justify-content: space-between;
		height: 180rpx;
		border: 1px #e6e6e6 solid;
		border-top: none;
	}

	.off-name {
		font-weight: bold;
		font-size: 30rpx;
		color: #333;
		overflow: hidden;
		display: -webkit-box;
		-webkit-line-clamp: 2;
		-webkit-box-orient: vertical;
	}

	.off-time {
		font-size: 24rpx;
		color: #4c4c4c;
	}

	.btn-wrap {
		width: 100%;
		background-color: #262626;
		position: fixed;
		bottom: 0;
		left: 0;
		z-index: 50;
	}

	.btn {
		height: 120rpx;
		display: flex;
		justify-content: center;
		align-items: center;
	}

	.btn1 {
		display: flex;
		justify-content: center;
		align-items: center;
		width: 540rpx;
		height: 80rpx;
		background-color: #f7d031;
		border-radius: 50rpx;
		font-size: 30rpx;
		color: #000;
	}

	.ticket-icon {
		margin-right: 20rpx;
		width: 38rpx;
		height: 30rpx;
	}

	.btn-margin {
		height: 120rpx;
		box-sizing: content-box;
	}
</style>
